#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int minNumberOfFrogs(string croakOfFrogs) {
        unordered_map<char, int>hashi = { {'c',0},{'r',0},{'o',0},{'a',0},{'k',0} };

        for (auto e : croakOfFrogs)
        {
            switch (e)
            {
            case 'c':
                if (hashi['k']) hashi['k']--;
                hashi['c']++;
                break;

            case 'r':
                if (hashi['c'] == 0) return -1;
                hashi['c']--, hashi['r']++;
                break;

            case 'o':
                if (hashi['r'] == 0) return -1;
                hashi['r']--, hashi['o']++;
                break;

            case 'a':
                if (hashi['o'] == 0) return -1;
                hashi['o']--, hashi['a']++;
                break;

            case 'k':
                if (hashi['a'] == 0) return -1;
                hashi['a']--, hashi['k']++;
                break;
            }
        }
        if (hashi['a'] || hashi['c'] || hashi['r'] || hashi['o']) return -1;
        return hashi['k'];
    }
};